const Web3 = require("web3");
describe('web3j 接口测试', function () {
    let node = "http://localhost:7545"
    let web3;
    it(' 连接以太坊节点 ', async function () {
        web3 = new Web3(new Web3.providers.HttpProvider(node));
    });
    it('web3--version', async function () {
        console.log(web3.version);
    });
    it('当前区块高度', async function () {
        let number = await web3.eth.getBlockNumber();
        console.log(number);
    });
    let blockTransactionString
    it('获取区块信息', async function () {
        blockTransactionString = await web3.eth.getBlock(180);
        console.log(blockTransactionString);
    });
    it('其中的交易笔数', async function () {
        console.log(blockTransactionString.transactions.length);
    });
    it('交易信息', async function () {
        for (let i = 0; i < blockTransactionString.transactions.length; i++) {
            console.log("*******************************************");
            let transaction = await web3.eth.getTransaction(blockTransactionString.transactions[i]);
            console.log(transaction);
        }
    });
});